// 每日金榜
<template lang='pug'>
.everyday
  Spbox(v-for="item in 3",:key="item.id")

</template>
<script>
import { pro } from '@/config/env'
import { unique } from '@/config/utils'
import fetch from '@/config/fetch'
import { getCommodityData } from '@/service/getData'
import Spbox from './_spbox'

export default {
  props:['cdata'],
  created() {
    this.getCommodityIdBtcArr()
    this.getCommodityIdArr()
    this.getCommodityList()
  },
  methods: {
    async getCommodityList() {
      let p = this.$store.state.position
      let commoditydata = await getCommodityData(p.cityCode, p.storeLocation, unique(this.commodityIdBtcArr))
      if (commoditydata.resultMsg == "成功") {
        this.commodityArr = commoditydata.resultData.splice(0,3)
      }
    },
    // 获取b2cids
    getCommodityIdBtcArr() {
      let arr = []
      this.cdata[0].tag.forEach(function (item) {
        arr.push(`${item.elementDesc || '0000000000'}-${item.elementName}`)
      })
      console.log(arr)
      this.commodityIdBtcArr = arr
    },
    getCommodityIdArr() {
      let arr = []
      this.cdata[0].tag.forEach(function (item) {
        arr.push(item.elementName)
      })
      this.commodityIdArr = unique(arr)
    },
  },
  components: {
    Spbox
  },
}
</script>
<style lang='scss' scoped>
@import './tool.scss';

</style>
